<?php

class ItemsController extends Controller {
	function view($id = NULL, $name = NULL) {
		$this->set('title', $name . ' - My Todo List');
		$this->set('todo', $this->Item->select($id));
	}
	
	function viewall() {
		$this->set('title', 'All items - My Todo List');
		$this->set('todo', $this->Item->selectAll());
	}
	
	function add() {
		$todo = $_POST['todo'];
		$this->set('title', 'Success - My Todo List');
		$this->set('todo',$this->Item->query('INSERT INTO items (item_name) VALUES (\''.$this->Item->escape($todo).'\')'));
	}
	
	function delete($id = NULL) {
		$this->set('title', 'Success - My Todo List');
		$this->set('todo',$this->Item->query('DELETE FROM items WHERE id =  \''.$this->Item->escape($id).'\''));
	}
}